package com.neutech.neufin.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.neutech.neufin.service.ExpenseClassService;
import com.neutech.neufin.vo.ViewData;
import com.neutech.po.ExpenseClass;


@RestController
@CrossOrigin("http://localhost:8081")//允许跨域请求的地址
@RequestMapping("/neuhis/expenseClass")
public class ExpenseClassController {
	@Autowired
	private ExpenseClassService expenseClassService;
	/**
	 * 显示所有ExpenseClass(费用科目表)中的数据
	 */
	@RequestMapping(value="/queryAll",method=RequestMethod.GET)
	public List<ExpenseClass> queryAll(){
		return expenseClassService.queryAll();	
	}
	
	
	
	/**
	 * 添加数据--ExpenseClass表中数据
	 * @param expenseClass
	 * @return
	 */
	@RequestMapping(value="/addNewExpenseClass",method=RequestMethod.POST)
	public String addNewExpenseClass(@RequestBody ExpenseClass expenseClass){
		int num =  expenseClassService.addNewExpenseClass(expenseClass);
		if(num == 1){
			return "添加成功";
		}else{
			return "添加失败";
		}
	}
	
	/**
	 * 指定查询条件显示expName="+expN"
	 */
	@RequestMapping(value="/getExps",method=RequestMethod.GET)
	public ViewData getExps(Map<String,Object> map){
		return expenseClassService.getExps(map);
		
	}
}
